package com.group2.bankonline.service.impl;

import com.group2.bankonline.pojo.Account;
import com.group2.bankonline.mapper.AccountMapper;
import com.group2.bankonline.pojo.Transrecord;
import com.group2.bankonline.service.IAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.math.BigDecimal;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author syf
 * @since 2024-07-11
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService {
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public int updateAccountBalance(int aid, BigDecimal balance) {
        return baseMapper.updateAccountBalance(balance,aid);
    }

    @Override
    public Account getByIdAndPassword(int id, String password) {
        return baseMapper.selectByIdAndPassword(id,password);
    }

    @Override
    public Integer getByAccountName(String name) {
        return baseMapper.selectByAccountName(name);
    }

    @Override
    public int selectTelById(int id) {
        return baseMapper.selectTelById(id);
    }

    @Override
    public Account bindAccount(Account account) {
        baseMapper.bindAccount(account);
        return null;
    }

    @Override
    public boolean havepid(int pid) {
        if(baseMapper.havepid(pid)){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Account> getaccountname(int pid) {
        return accountMapper.getaccountname(pid);
    }

    @Override
    public int getpid(String accountname) {
        return 0;
    }

    @Override
    public BigDecimal getBalance(String accountname) {
        return  baseMapper.getBalance(accountname);
    }

    @Override
    public void accountchange(BigDecimal newbalance,String accountname) {
        baseMapper.accountchange(newbalance,accountname);
    }

    @Override
    public String getpwd(String accountname) {
        return baseMapper.getpwd(accountname);
    }

    @Override
    public int getid(String accountname) {
        return baseMapper.getid(accountname);
    }

}
